/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lucava.metamodel.uspeed;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import lucava.metamodel.uspeed.visitor.IElementVisitor;

/**
 *
 * @author glenn
 */
public class UspeedDocument extends NamedElement {

    /**
     * Map des classes du document.
     */
    private HashMap<String, ClassElement> classes = new HashMap<String, ClassElement>();

    public Boolean hasClass(String className) {
        return classes.containsKey(className);
    }

    public Collection<ClassElement> getClasses() {
        return classes.values();
    }

    public ClassElement getClass(String className) {
        return classes.get(className);
    }

    public void addClass(String className, ClassElement elmt) {
        classes.put(className, elmt);
    }

    @Override
    public void accept(IElementVisitor visitor) {
        visitor.enterDocument(this);
        Iterator<ClassElement> it = this.classes.values().iterator();
        while (it.hasNext()) {
            ClassElement elmt = it.next();
            elmt.accept(visitor);
        }
        visitor.leaveDocument(this);
    }
}
